import {
  baseUrl
} from "../config/index"

export const $https = ({
  url = "",
  method = 'GET',
  data = {}
}) => {



  return new Promise(function (resolve, reject) {

    let header = {
      'content-type': 'application/json' // 默认值
    }
    var token = wx.getStorageSync('token')
    if (token) {
      header.token = token
    }

    wx.request({
      url: `${baseUrl}${url}`, //仅为示例，并非真实的接口地址
      data: data,
      header: header,
      method,
      success(res) {
        console.log(res, "以发送请求")
        resolve(res.data)
      },
      fail(err) {
        wx.showToast({ title: '网络异常', icon: 'none' });
        reject(err)
      }
    })
  })

};